using ASP;
using HoWave.Common;
using HoWave.Web;
using HoWave.Web.Admin;
using System;
using System.Collections;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
public class HL_Admin_Admin_HowavePayType : Admin, IRequiresSessionState
{
	protected ScriptManager ScriptManager1;
	protected TextBox TextBox1;
	protected DropDownList DropDownList1;
	protected DropDownList DropDownList2;
	protected UpdatePanel UpdatePanel1;
	protected Button btn_cearchType;
	protected GridView GridView1;
	protected Label PagePanel;
	private Shop_PayType _paytype = null;
	private UserBll _user = null;
	private string wherestr = "";
	private string linkhead = "";
	private IDbDataParameter[] param;
	private ArrayList al = new ArrayList();
	private bool tag = true;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected Shop_PayType m_paytype
	{
		get
		{
			Shop_PayType paytype;
			if (this._paytype == null)
			{
				this._paytype = new Shop_PayType(this.conn);
				paytype = this._paytype;
			}
			else
			{
				paytype = this._paytype;
			}
			return paytype;
		}
	}
	protected UserBll user
	{
		get
		{
			UserBll user;
			if (this._user == null)
			{
				this._user = new UserBll(this.conn);
				user = this._user;
			}
			else
			{
				user = this._user;
			}
			return user;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.admin.CheckAdminPower(112))
		{
			base.WriteLog("View", Language.GetAdminMsg("Log/Access", "0"), "PayType");
			base.WriteRightErrMsg();
		}
		if (!base.IsPostBack)
		{
			this.BindList();
			this.DropDownList2.Enabled = false;
		}
	}
	protected void BindList()
	{
		this.QueryString();
		int num = Fetch.GetID("page");
		if (num <= 0)
		{
			num = 1;
		}
		int pageSize = this.GridView1.PageSize;
		if (this.al.Count > 0)
		{
			this.param = new IDbDataParameter[this.al.Count];
			this.al.CopyTo(this.param, 0);
		}
		if (this.param != null)
		{
			this.GridView1.DataSource = this.m_paytype.GetAllPayType(num, pageSize, this.wherestr, "", this.param);
		}
		else
		{
			this.GridView1.DataSource = this.m_paytype.GetAllPayType(num, pageSize, this.wherestr, "");
		}
		this.GridView1.DataBind();
		this.PagePanel.Text = this.m_paytype.GetPagePanel(this.linkhead);
	}
	protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
	{
		if (!base.admin.CheckAdminPower(113))
		{
			base.WriteLog("Check", Language.GetAdminMsg("Log/Access", "0"), "PayType");
			base.WriteRightErrMsg();
		}
		this.m_paytype.SetPayTypeAsDefault(0, int.Parse(this.GridView1.SelectedRow.Cells[0].Text));
		this.tag = false;
		this.BindList();
	}
	protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		bool flag = base.admin.CheckAdminPower(113);
		bool flag2 = base.admin.CheckAdminPower(114);
		bool flag3 = base.admin.CheckAdminPower(115);
		if (e.Row.RowType == DataControlRowType.DataRow)
		{
			e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#E7EDFE'");
			e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
			if (!flag2)
			{
				((LinkButton)e.Row.FindControl("cl")).Enabled = false;
			}
			if (!flag2)
			{
				e.Row.Cells[6].Enabled = false;
			}
			if (!flag3)
			{
				e.Row.Cells[7].Enabled = false;
			}
		}
	}
	protected void Delete_ButtonClick(object sender, CommandEventArgs e)
	{
		if (base.admin.CheckAdminPower(114))
		{
			int num = 0;
			try
			{
				num = Convert.ToInt32(e.CommandArgument.ToString());
			}
			catch
			{
				this.WriteErrMsg("", Language.GetAdminMsg("Common/ParamErr"), "");
			}
			if (num > 0)
			{
				if (this.m_paytype.DeleteType(num, 0))
				{
					this.BindList();
				}
				else
				{
					this.WriteErrMsg("", Language.GetAdminMsg("Common/ParamErr"), "");
				}
			}
			else
			{
				this.WriteErrMsg("", Language.GetAdminMsg("Common/ParamErr"), "");
			}
		}
		else
		{
			base.WriteLog("Delete", Language.GetAdminMsg("Log/Access", "0"), "PayType");
			base.WriteRightErrMsg();
		}
	}
	protected void QueryString()
	{
		string text;
		if (Fetch.Get("userName") != string.Empty && this.tag)
		{
			text = (this.TextBox1.Text = Fetch.Get("userName"));
		}
		else
		{
			text = this.TextBox1.Text;
		}
		if (text != string.Empty)
		{
			this.wherestr += "and UserID in(select UserID From [HL_User] Where UserName like '%' + @UserName + '%') ";
			this.al.Add(this.conn.CreateParameter("@UserName", DbType.String, text));
			this.linkhead = this.linkhead + "&userName=" + base.Server.UrlEncode(text);
		}
		int num;
		if (Fetch.GetID("type") > 0 && this.tag)
		{
			num = (this.DropDownList1.SelectedIndex = Fetch.GetID("type"));
		}
		else
		{
			num = this.DropDownList1.SelectedIndex;
		}
		int num2;
		if (Fetch.GetID("type2") > 0 && this.tag)
		{
			num2 = (this.DropDownList2.SelectedIndex = Fetch.GetID("type2"));
		}
		else
		{
			num2 = this.DropDownList2.SelectedIndex;
		}
		if (num != 0)
		{
			if (num2 == 0)
			{
				this.wherestr = this.wherestr + "and PayType = " + this.DropDownList1.SelectedValue;
			}
			else
			{
				this.wherestr = this.wherestr + "and OnlinePay= '" + this.DropDownList2.SelectedValue + "'";
				this.linkhead = this.linkhead + "&type2=" + num2;
			}
			this.linkhead = this.linkhead + "&type=" + num;
		}
		if (this.wherestr != string.Empty)
		{
			this.wherestr = this.wherestr.Substring(3);
			this.wherestr = "where" + this.wherestr;
		}
	}
	protected void btn_cearchType_Click(object sender, EventArgs e)
	{
		this.tag = false;
		this.BindList();
	}
	protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
	{
		if (this.DropDownList1.SelectedIndex == 0)
		{
			this.DropDownList2.Enabled = false;
			this.DropDownList2.Items.Clear();
			ListItem listItem = new ListItem();
			listItem.Text = Language.Get("Shop/PayType/payTypeName0");
			listItem.Value = Language.Get("Shop/PayType/payTypeName0");
			this.DropDownList2.Items.Add(listItem);
		}
		else
		{
			if (this.DropDownList1.SelectedIndex == 1)
			{
				this.DropDownList2.Enabled = true;
				this.DropDownList2.Items.Clear();
				ListItem listItem = new ListItem();
				listItem.Text = Language.Get("Shop/PayType/payTypeName0");
				listItem.Value = Language.Get("Shop/PayType/payTypeName0");
				this.DropDownList2.Items.Add(listItem);
				ListItem listItem2 = new ListItem();
				listItem2.Text = Language.Get("Shop/PayType/payTypeName1");
				listItem2.Value = Language.Get("Shop/PayType/payTypeName1");
				this.DropDownList2.Items.Add(listItem2);
			}
			else
			{
				if (this.DropDownList1.SelectedIndex == 2)
				{
					this.DropDownList2.Enabled = true;
					this.DropDownList2.Items.Clear();
					ListItem listItem = new ListItem();
					listItem.Text = Language.Get("Shop/DownLinePay/DownPayTypeName0");
					listItem.Value = Language.Get("Shop/DownLinePay/DownPayTypeName0");
					this.DropDownList2.Items.Add(listItem);
					ListItem listItem2 = new ListItem();
					listItem2.Text = Language.Get("Shop/DownLinePay/DownPayTypeName1");
					listItem2.Value = Language.Get("Shop/DownLinePay/DownPayTypeName1");
					this.DropDownList2.Items.Add(listItem2);
					ListItem listItem3 = new ListItem();
					listItem3.Text = Language.Get("Shop/DownLinePay/DownPayTypeName2");
					listItem3.Value = Language.Get("Shop/DownLinePay/DownPayTypeName2");
					this.DropDownList2.Items.Add(listItem3);
					ListItem listItem4 = new ListItem();
					listItem4.Text = Language.Get("Shop/DownLinePay/DownPayTypeName3");
					listItem4.Value = Language.Get("Shop/DownLinePay/DownPayTypeName3");
					this.DropDownList2.Items.Add(listItem4);
					ListItem listItem5 = new ListItem();
					listItem5.Text = Language.Get("Shop/DownLinePay/DownPayTypeName4");
					listItem5.Value = Language.Get("Shop/DownLinePay/DownPayTypeName4");
					this.DropDownList2.Items.Add(listItem5);
					ListItem listItem6 = new ListItem();
					listItem6.Text = Language.Get("Shop/DownLinePay/DownPayTypeName5");
					listItem6.Value = Language.Get("Shop/DownLinePay/DownPayTypeName5");
					this.DropDownList2.Items.Add(listItem6);
				}
			}
		}
	}
	protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
	{
	}
	protected void lb_enable_Command(object sender, CommandEventArgs e)
	{
		if (base.admin.CheckAdminPower(115))
		{
			int num = 0;
			try
			{
				num = Convert.ToInt32(e.CommandArgument.ToString());
			}
			catch
			{
				this.WriteErrMsg("", Language.GetAdminMsg("Common/ParamErr"), "");
			}
			if (num > 0)
			{
				DataTable typeByID = this.m_paytype.GetTypeByID(num);
				bool flag = (bool)typeByID.Rows[0]["IsDisabled"];
				if (this.m_paytype.SetDisenabled(!flag, num))
				{
					this.BindList();
				}
				else
				{
					this.WriteErrMsg("", Language.GetAdminMsg("Common/ParamErr"), "");
				}
			}
			else
			{
				this.WriteErrMsg("", Language.GetAdminMsg("Common/ParamErr"), "");
			}
		}
		else
		{
			base.WriteLog("Check", Language.GetAdminMsg("Log/Access", "0"), "PayType");
			base.WriteRightErrMsg();
		}
	}
}
